package com.mfin.bom.adapter;

import com.mfin.bom.interfaces.IFinance;
import com.mfin.bom.interfaces.IUser;
import com.mfin.bom.objects.User;
import com.mfin.enumeration.UserRole;
import com.mfin.vo.ObjectKey;

public class UserAdapter extends IIdentifiableAdapter implements IUser {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7753515569621531199L;

	private User wrappedUser = null;

	public UserAdapter(User wrappedUser, ObjectKey[] keys) {
		super();
		this.wrappedUser = wrappedUser;
		ObjectKey[] newKeys = new ObjectKey[2];
		newKeys[0] = keys[0];
		newKeys[1] = new ObjectKey(wrappedUser.getId());
		setKeys(newKeys);
	}

	public User getUser() {
		return wrappedUser;
	}

	@Override
	public String getUserId() {
		return wrappedUser.getId();
	}

	@Override
	public void setUserId(String id) {
		wrappedUser.setId(id);
	}

	@Override
	public IFinance getFinance() {
		return new FinanceAdapter(wrappedUser.getFinance());
	}

	@Override
	public void setFinance(IFinance bomFinanceInformation) {

		if (bomFinanceInformation != null) {
			FinanceAdapter financeInformationAdapter = (FinanceAdapter) bomFinanceInformation;
			wrappedUser.setFinance(financeInformationAdapter.getFinance());
		}
	}

	@Override
	public String getPassword() {
		return wrappedUser.getPassword();
	}

	@Override
	public void setPassword(String password) {
		wrappedUser.setPassword(password);
	}

	@Override
	public UserRole getRole() {
		return wrappedUser.getRole();
	}

	@Override
	public void setRole(UserRole role) {
		wrappedUser.setRole(role);
	}
}
